export const commandName = 'commandName', commandLevel = 'commandLevel';
export const commandSplit = 'v-', commandType = 'commandType';

export const renderType = 'render', createNodeType = 'createNode';
export const bindType = 'bind', inputType = 'input', eventType = 'event'

const commands = [
  {
    type: renderType,
    values: [
      {[commandName]: 'once', [commandLevel]: 100},
      {[commandName]: 'if', [commandLevel]: 3},
      {[commandName]: 'show', [commandLevel]: 2},
      {[commandName]: 'for', [commandLevel]: 1},
    ]
  },
  {
    type: createNodeType,
    values: [
      {[commandName]: 'html', [commandLevel]: 2},
      {[commandName]: 'text', [commandLevel]: 1},
    ]
  },
  {
    type: bindType,
    values: [
      {[commandName]: 'bind', [commandLevel]: 1},
    ]
  },
  {
    type: inputType,
    values: [
      {[commandName]: 'model', [commandLevel]: 1},
    ]
  },
  {
    type: eventType,
    values: [
      {[commandName]: 'on', [commandLevel]: 1},
    ]
  },
]

//  todo 数据一致性处理， 这点数据循环性能完全可不计
export const commandsFormat = commands.map(command => {
  return {
    ...command,
    values: command.values.map(item => {
      return {
        ...item,
        [commandName]: commandSplit + item[commandName]
      }
    })
  }
});

// 解析命令
export const commandHandler = {
  [renderType](state, actionType){
    console.log(state,actionType,'fff');
  },
}
